import * as API from 'server/getData'
import * as types from 'store/mutations_types.js'

export default {
    async login_user({ commit, state }, payload) {
        let data = await API.user.fetchUser()
        if (data.success === true) {
            commit(types.LOGIN, data.data)
            // 设置专属tabBar
            state.tabBar[state.user.role].forEach(e => {
            	uni.setTabBarItem(e)
            })
        } else {
            commit(types.LOGOUT)
        }
    }
}